home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr48 / tsbat146.zip / WEEKLY.BAT < prev    next >
DOS Batch File  |  1992-09-20  |  2KB  |  72 lines

  1. @echo off
  2. echo.
  3. echo ┌───────────────────────────────────────────────────┐
  4. echo │ Run an application once a week at boot time       │
  5. echo │ By Prof. Timo Salmi, ts@uwasa.fi, Sun 20-Sep-1992 │
  6. echo └───────────────────────────────────────────────────┘
  7.  
  8. if "%2"=="" goto _help
  9.  
  10. rem Check the weekday syntax
  11. set found_=
  12. for %%d in (Sun Mon Tue Wed Thu Fri Sat) do if "%1"=="%%d" set found_=yes
  13. if "%found_%"=="yes" goto _getday
  14. echo Error in the first parameter %1
  15. echo The valid weekdays are Sun Mon Tue Wed Thu Fri Sat
  16. goto _out
  17.  
  18. rem Get the weekday into an environment variable
  19. :_getday
  20. echo.| date | find "Current" > tmp$$$.bat
  21. echo set weekday_=%%3> current.bat
  22. call tmp$$$
  23. if exist tmp$$$.bat del tmp$$$.bat
  24. if exist current.bat del current.bat
  25.  
  26. rem Are we at the target weekday
  27. if "%weekday_%"=="%1" goto _compare
  28. echo It is not %1 today
  29. goto _out
  30.  
  31. rem Check when this batch was last run
  32. :_compare
  33. if not exist last%1.$$$ goto _doit
  34. echo.|date> datenow.$$$
  35. fc datenow.$$$ last%1.$$$ > tmp$$$
  36. del datenow.$$$
  37. type tmp$$$ | find "no differences encountered" > same$$$
  38. del tmp$$$
  39. copy same$$$ dont$$$ > nul
  40. del same$$$
  41. if not exist dont$$$ goto _doit
  42. del dont$$$
  43. echo WEEKLY.BAT already run today on %1
  44. goto _out
  45.  
  46. rem Call the application
  47. :_doit
  48. call %2 %3 %4 %5 %6 %7 %8 %9
  49. echo.|date> last%1.$$$
  50. goto _out
  51.  
  52. :_help
  53. echo.
  54. echo If you want to run a program once a week when you reboot your
  55. echo computer, put
  56. echo   CALL WEEKLY Weekday YourApplicationName [Param1] [Param2] [...]
  57. echo in your autoexec.bat file.
  58. echo.
  59. echo Only one application, or one set of applications, can be run on the
  60. echo same weekday with this batch. The application can be a different one
  61. echo for each weekday.
  62. echo.
  63. echo Examples:
  64. echo   CALL WEEKLY Mon YourApplication
  65. echo   CALL WEEKLY Tue echo Time to back up^G^G^G
  66. echo   CALL WEEKLY Fri call YourBatchOfManyPrograms
  67. echo.
  68.  
  69. :_out
  70. set weekday_=
  71. set found=
  72.